package ws.jonas.hoarder.db;

import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import ws.jonas.common.config.Config;
import ws.jonas.common.log.Logger;

public class MysqlDb extends SqlDb {
	private static final Logger log = Logger.getInstance(MysqlDb.class);

	public MysqlDb() throws SQLException {
		Properties props = new Properties();
		props.put("user", Config.get(Config.DB_USER_KEY));
		props.put("password", Config.get(Config.DB_PASSWORD_KEY));
		props.put("characterEncoding", "UTF-8");
		try {
			conn = DriverManager.getConnection("jdbc:mysql://" + Config.get(Config.DB_KEY), props);
		} catch (SQLException e) {
			log.severe("Could not set up database connection, shutting down: " + e.getMessage());
			throw(e);
		}

		prepareStatements();
	}
}
